翻訳と辞書
Words near each other
・ Elephant Gambit
・ Elephant games
・ Elephant garlic
・ Elephant Gate and Tower, Carlsberg
・ Elephant goad
・ Elephant grass
・ Elephant gun
・ Elephant Gun (EP)
・ Elephant Head Lodge
・ Elephant Hill Provincial Park
・ Elephant Hotel
・ Elephant hotel
・ Elephant House
・ Elephant hunting in Chad
・ Elephant hunting in Kenya
Elephant in Cairo
・ Elephant in the room
・ Elephant in the room (disambiguation)
・ Elephant Island
・ Elephant Jason Island
・ Elephant joke
・ Elephant Jokes
・ Elephant Kashimashi
・ Elephant King
・ Elephant Lagoon
・ Elephant Larry
・ Elephant Man (comics)
・ Elephant Man (musician)
・ Elephant Man discography
・ Elephant Marsh


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Elephant in Cairo : ウィキペディア英語版
Elephant in Cairo

An elephant in Cairo is a term used in computer programming to describe a piece of data inserted at the end of a search space, which matches the search criteria, in order to make sure the search algorithm terminates; it is a humorous example of a sentinel value. The term derives from a humorous essay circulated on the Internet and published in ''Byte'' magazine in September 1989 that described how various professions would go about hunting elephants.
==Algorithm==
When hunting elephants, the article describes programmers as following this algorithm:
:# Go to Africa.
:# Start at the Cape of Good Hope.
:# Work northward in an orderly manner, traversing the continent alternately east and west,
:# During each traverse pass:
:#:
* Catch each animal seen.
:#:
* Compare each animal caught to a known elephant.
:#:
* Stop when a match is detected.
This algorithm has a bug, namely a bounds checking error: if no elephants are found, the programmer will continue northwards and end up in the Mediterranean sea, causing abnormal termination.
Thus experienced programmers modify the above algorithm by placing a known elephant in Cairo to ensure that the algorithm will terminate. The modified algorithm is therefore as follows:
:# Go to Africa.
:# Put an elephant in Cairo.
:# Start at the Cape of Good Hope.
:# Work northward in an orderly manner, traversing the continent alternately east and west,
:# During each traverse pass:
:#:
* Catch each animal seen.
:#:
* Compare each animal caught to a known elephant.
:#:
* Stop when a match is detected.
:# If you are in Cairo, then there are no elephants in Africa (other than the one you placed there).

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Elephant in Cairo」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.